﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace db
{
    public partial class Deposito : IObservable<Object>
    {
        private List<IObserver<Object>> _listaObservadores = new List<IObserver<Object>>();

        #region IObservable<object> Members

        public IDisposable  Subscribe(IObserver<object> observer)
        {
            if (!_listaObservadores.Contains(observer))
                _listaObservadores.Add(observer);
            return new Unsubscriber(_listaObservadores, observer);
        }

        #endregion

        private class Unsubscriber : IDisposable
        {
            private List<IObserver<Object>> _observers;
            private IObserver<Object> _observer;

            public Unsubscriber(List<IObserver<Object>> observers, IObserver<Object> observer)
            {
                this._observers = observers;
                this._observer = observer;
            }

            public void Dispose()
            {
                if (_observer != null && _observers.Contains(_observer))
                    _observers.Remove(_observer);
            }

           
        }
        public List<Sector> getSectores()
        {
            return this.Sector.ToList<Sector>();
        }



}
}
